<?php
/**
 * DotHerbert
 *
 * @package    UnitTest
 * @copyright  2009 extreme-programmers
 * @license    http://dotherbert.extreme-programmers.com/license   BSD License
 * @version    $Id: TestDirectoryIterator.php 102 2009-05-13 17:19:29Z johannes.trink@extreme-programmers.com $
 */

namespace dotherbert\unittest;
use dotherbert\core\stub;

/**
 * TestDirectory iterator
 *
 * @package    UnitTest
 * @author     Johannes Trink <johannes.trink@extreme-programmers.com>
 */
class TestDirectoryIterator extends \FilterIterator
{
    /**
     * Accept
     *
     * @return accept
     */
    public function accept()
    {
        $file = $this->getInnerIterator()->current();
        if (($file->isDir()) and (!$file->isDot())) {
            $allTestsPath = $file->getPathname() . DIRECTORY_SEPARATOR . 'AllTests.php';
            if (stub\FilesystemStub::getInstance()->fileExists($allTestsPath)) {
                return true;
            }
        }
        return false;
    }
}